import { PartialType } from '@nestjs/swagger';
import { CreateUserDto } from './create-user.dto';
import { IsOptional, IsString, IsEmail, Length, IsUrl } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class UpdateUserDto extends PartialType(CreateUserDto) {
  @ApiProperty({ description: '用户名', required: false })
  @IsOptional()
  @IsString({ message: '用户名必须是字符串' })
  @Length(2, 50, { message: '用户名长度在2-50个字符之间' })
  username?: string;
  
  @ApiProperty({ description: '昵称', required: false })
  @IsOptional()
  @IsString({ message: '昵称必须是字符串' })
  @Length(2, 50, { message: '昵称长度在2-50个字符之间' })
  nickname?: string;

  @ApiProperty({ description: '邮箱', required: false })
  @IsOptional()
  @IsEmail({}, { message: '请提供有效的邮箱地址' })
  email?: string;

  @ApiProperty({ description: '密码', required: false })
  @IsOptional()
  @IsString({ message: '密码必须是字符串' })
  @Length(6, 100, { message: '密码长度在6-100个字符之间' })
  password?: string;

  @ApiProperty({ description: '头像URL', required: false })
  @IsOptional()
  @IsUrl({}, { message: '请提供有效的URL' })
  avatar?: string;

  @ApiProperty({ description: '个人简介', required: false })
  @IsOptional()
  @IsString({ message: '个人简介必须是字符串' })
  bio?: string;
}